<!--
 * @Description: 
 * @version: 
 * @Author: King
 * @Date: 2022-03-05 14:22:52
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-05-11 17:17:34
-->
<template>
  <div class="container-pageOne">
    {{this.DbSourceOne}}
      <el-button @click="changeStateOne">点击</el-button>
      {{this.newArr}}
      <el-button @click="unique">点击排序</el-button>
       <!-- {{this.result}}
      <el-button @click="test">点击查看result结果</el-button> -->
      <!-- <div class="ones">1</div>
      <div class="ones">2</div>
      <div class="ones">3</div>
      <div class="ones">4</div>
      <div class="ones">5</div>
      <div class="ones">6</div>
      <div class="ones">7</div>
      <div class="ones">8</div>
      <div class="ones">9</div>
      <div class="ones">10</div> -->
  </div>
</template>

<script>
import {fetchFavicons} from '@meltwater/fetch-favicon'
import {mapActions,mapState} from 'vuex'
export default {
  name:'PageOne',
  data(){
    return {
      // DbSources:'',
      // 初始化要得到的数组数据
      newArr:'',
      result:[]
    }
  },
  computed:{
    // ...mapState(['DbSource'])
    // 模块化写法
    ...mapState({
      DbSourceOne: state => state.DbSource,
    }),
  },
  created(){
    this.do()
    // console.log(this.title,'哈哈哈')
  },
  methods:{
    // 拿到actions.js中生命过的函数，可以在此组建中直接this.函数名，直接使用了
    ...mapActions(['saveDbSource']),
    changeStateOne(){
      this.queryFormOne = 100
      this.saveDbSource(this.queryFormOne)
    },
    unique() {
      let arr = [1, 1, 2, 3, 5, 3, 1, 5, 6, 7, 4]
      this.newArr = [arr[0]]
      for (let i = 1; i < arr.length; i++) {
          let repeat = false;
          for (let j = 0; j < this.newArr.length; j++) {
              if (arr[i] === this.newArr[j]) {
                  repeat = true;
                  break;
              }else{
                  console.log('000000')
                  // return repeat = false
              }
          }
          if (!repeat) {
              this.newArr.push(arr[i]);
          }
      }
      return this.newArr
    },
    do(){
      fetchFavicons('https://www.github.com')
    }
    // test(){
    //   for(let i = 0; i < 10; i++) {
    //     this.result.push(i)
    //     if(i == 9){
    //       break
    //     }
    //   }
    // },
   
  }
}
</script>

<style lang='scss' scoped>
 
.container-pageOne{
  overflow: auto; //使其内容高度不变，超出出现滚动条
 
  height: 100%;
  width: 100%;
  background-color: #fff;
  .ones{
    height: 500px;
    width: 200px;
    border: 1px solid blue;
  }

}
</style>